import { reqSearchListData } from "@/api";

const state = {
    searchGoodsInfo : {}
}

const getters = {
    attrsList(state){
        return state.searchGoodsInfo.attrsList
    },
    goodsList(state){
        return state.searchGoodsInfo.goodsList
    },
    trademarkList(state){
        return state.searchGoodsInfo.trademarkList
    },
    total(state){
        return state.searchGoodsInfo.total
    }
}

const actions = {
    //发送请求，获取searchGoodsInfo的数据
    async getSearchGoodsInfoData({commit},searchParams){
        const result = await reqSearchListData(searchParams)
        if(result.code === 200){
            commit('UPDATE_SEARCH_GOODS_LIST_DATA',result.data)
        }else{
            console.log('请求searchGoodsInfo数据失败',result.message);
        }
    }
}

const mutations = {
    UPDATE_SEARCH_GOODS_LIST_DATA(state,payload){
        state.searchGoodsInfo = payload
    }
}

export default {
    namespaced:true,
    state,
    getters,
    actions,
    mutations,
}